<?php
namespace Admin\Controller;
class NavigationController extends BaceController{
    public function navigation_add() {
        //添加导航
       if (!empty($_POST)) {
           $name=$_POST['name'];
           if(mb_strlen($name)<1) {
               $this->ajaxReturn(array('pass'=>0,'msg'=>'导航不能为空！'));
           }
           $re=M('Navigation')->data($_POST)->add();
           if ($re) {
               $this->ajaxReturn(array('pass'=>1,'msg'=>'添加成功'));
           }
       }
       //查找出所有导航
       $arr=M('Navigation')->select();
       $this->assign('arr',$arr);
        $this->display();
    }
    //删除
    function navigation_delete() {
        $id=$_POST['id'];
        $re=M('Navigation')->where("id=$id")->delete();
        $this->ajaxReturn(array('pass'=>1,'msg'=>'删除成功'));
    } 
    //修改
    function navigation_save() {
       $name= $_GET['name'];
       $this->assign("name",$name);
       $id=$_GET['id'];
       $this->assign("id",$id);

       
       if ($_POST) {
           ;
           if (mb_strlen($_POST['name']) <1) {
               $this->ajaxReturn(array('pass'=>0,'msg'=>'导航不能为空'));
           }
           $id=$_POST['id'];
           $re=M('Navigation')->where("id=$id")->data($_POST)->save();
           if ($re) {
               $this->ajaxReturn(array('pass'=>1,'msg'=>'操作成功'));
           }
       }
       $this->display();
    } 
}